package com.duolebo.uteped_sdk.model;

import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;

import com.yc.nadalsdk.bean.FitnessHeartRateData;
import com.yc.nadalsdk.bean.SleepData;

import java.util.ArrayList;

/**
 * @Author: wudapeng
 * @Date: 2023/12/20 15:49
 * @Description:
 */
public class HeartRateModel extends BaseModel {

    private String calendarTime;
    private String calendar;
    private int time;
    private int startTime;
    private int rate;
    private int restingHeartRate;
    private int dynamicHeartRate;
    private int heartRateMax;
    private int heartRateMin;

    public String getCalendarTime() {
        return calendarTime;
    }

    public void setCalendarTime(String calendarTime) {
        this.calendarTime = calendarTime;
    }

    public String getCalendar() {
        return calendar;
    }

    public void setCalendar(String calendar) {
        this.calendar = calendar;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public int getStartTime() {
        return startTime;
    }

    public void setStartTime(int startTime) {
        this.startTime = startTime;
    }

    public int getRate() {
        return rate;
    }

    public void setRate(int rate) {
        this.rate = rate;
    }

    public int getRestingHeartRate() {
        return restingHeartRate;
    }

    public void setRestingHeartRate(int restingHeartRate) {
        this.restingHeartRate = restingHeartRate;
    }

    public int getDynamicHeartRate() {
        return dynamicHeartRate;
    }

    public void setDynamicHeartRate(int dynamicHeartRate) {
        this.dynamicHeartRate = dynamicHeartRate;
    }

    public int getHeartRateMax() {
        return heartRateMax;
    }

    public void setHeartRateMax(int heartRateMax) {
        this.heartRateMax = heartRateMax;
    }

    public int getHeartRateMin() {
        return heartRateMin;
    }

    public void setHeartRateMin(int heartRateMin) {
        this.heartRateMin = heartRateMin;
    }

    public int getHeartRateAvg() {
        return heartRateAvg;
    }

    public void setHeartRateAvg(int heartRateAvg) {
        this.heartRateAvg = heartRateAvg;
    }

    private int heartRateAvg;

    public HeartRateModel(FitnessHeartRateData hrData) {
        this.calendar = hrData.getCalendar();
        this.calendarTime = hrData.getCalendarTime();
        this.time = hrData.getTime();
        this.startTime = hrData.getStartTime();
        this.rate = hrData.getRate();
        this.restingHeartRate = hrData.getRestingHeartRate();
        this.dynamicHeartRate = hrData.getDynamicHeartRate();
        this.heartRateMax = hrData.getHeartRateMax();
        this.heartRateMin = hrData.getHeartRateMin();
        this.heartRateAvg = hrData.getHeartRateAvg();
    }

    public HeartRateModel(){}

    /**
     * BaseModel
     *
     * @param model model
     */
    HeartRateModel(BaseModel model) {
        super(model);
    }

    @Override
    public void writeFieldValues(ContentValues values) {
        super.writeFieldValues(values);
        values.put(HartRateFields.CALENDAR_TIME, calendarTime);
        values.put(HartRateFields.CALENDAR, calendar);
        values.put(HartRateFields.TIME, time);
        values.put(HartRateFields.START_TIME, startTime);
        values.put(HartRateFields.RATE, rate);
        values.put(HartRateFields.RESTING_HEART_RATE, restingHeartRate);
        values.put(HartRateFields.DYNAMIC_HEART_RATE, dynamicHeartRate);
        values.put(HartRateFields.HEART_RATE_MAX, heartRateMax);
        values.put(HartRateFields.HEART_RATE_MIN, heartRateMin);
        values.put(HartRateFields.HEART_RATE_AVG, heartRateAvg);
    }

    @SuppressLint("Range")
    @Override
    public void readFieldValues(Cursor c) {
        super.readFieldValues(c);
        calendarTime = c.getString(c.getColumnIndex(HartRateFields.CALENDAR_TIME));
        calendar = c.getString(c.getColumnIndex(HartRateFields.CALENDAR));
        time = c.getInt(c.getColumnIndex(HartRateFields.TIME));
        startTime = c.getInt(c.getColumnIndex(HartRateFields.START_TIME));
        rate = c.getInt(c.getColumnIndex(HartRateFields.RATE));
        restingHeartRate = c.getInt(c.getColumnIndex(HartRateFields.RESTING_HEART_RATE));
        dynamicHeartRate = c.getInt(c.getColumnIndex(HartRateFields.DYNAMIC_HEART_RATE));
        heartRateMax = c.getInt(c.getColumnIndex(HartRateFields.HEART_RATE_MAX));
        heartRateMin = c.getInt(c.getColumnIndex(HartRateFields.HEART_RATE_MIN));
        heartRateAvg = c.getInt(c.getColumnIndex(HartRateFields.HEART_RATE_AVG));
    }

    @Override
    public void prepareFieldDefs(ArrayList<String> fieldDefs) {
        super.prepareFieldDefs(fieldDefs);
        fieldDefs.add(HartRateFields.CALENDAR_TIME + FIELD_TYPE_TEXT);
        fieldDefs.add(HartRateFields.CALENDAR + FIELD_TYPE_TEXT);
        fieldDefs.add(HartRateFields.TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.START_TIME + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.RATE + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.RESTING_HEART_RATE + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.DYNAMIC_HEART_RATE + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.HEART_RATE_MAX + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.HEART_RATE_MIN + FIELD_TYPE_INTEGER);
        fieldDefs.add(HartRateFields.HEART_RATE_AVG + FIELD_TYPE_INTEGER);
    }

    public static class HartRateFields implements Fields {
        public static final String CALENDAR_TIME = "calendar_time";
        public static final String CALENDAR = "calendar";
        public static final String TIME = "time";
        public static final String START_TIME = "start_time";
        public static final String RATE = "rate";
        public static final String RESTING_HEART_RATE = "resting_heart_rate";
        public static final String DYNAMIC_HEART_RATE = "dynamic_heart_rate";
        public static final String HEART_RATE_MAX = "heart_rate_max";
        public static final String HEART_RATE_MIN = "heart_rate_min";
        public static final String HEART_RATE_AVG = "heart_rate_avg";
    }

}
